﻿using CommonUtils;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using You.Respository;

namespace You.Client
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //初始化路径
            PathManager.Init();
            PathManager.IsUseMapperXMLFile = false;//mapper.xml文件作为嵌入的资源,可作为隐藏sql使用 
            //PathManager.IsUseMapperXMLFile = true;//mapper.xml文件生成时复制到输出目录,可后续进行更改,重启生效
            //检测目标数据库是否存在，不存在则复制原始数据库文件到目标位置
            if (!FileFolderHelper.IsFileExist(PathManager.AppConfigDbPath))
            {
                string originalDbFilePath = System.IO.Path.Combine(PathManager.AppRoot, "Database\\Sqlite\\data.db");
                if (FileFolderHelper.IsFileExist(originalDbFilePath))
                {
                    FileFolderHelper.Copy(originalDbFilePath, PathManager.AppConfigDbPath);
                }
            }

            //测试数据库
            TestRespository testRespository = new TestRespository();
            var list = testRespository.GetList();
            //测试xml输出文件
            PathManager.IsUseMapperXMLFile = true;//mapper.xml文件生成时复制到输出目录,可后续进行更改,重启生效
            AccountUserRespository accountUserRespository = new AccountUserRespository();
            var list2 = accountUserRespository.GetList();
        }
    }
}
